package logic

import (
	"context"
	"fmt"
	"goods_srv/models/mysql"

	"goods_srv/goodssrv"
	"goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserExitLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserExitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserExitLogic {
	return &UserExitLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserExitLogic) UserExit(in *goodssrv.UserExitRequest) (*goodssrv.UserExitResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	user.Status = 0
	err := user.UserExit(int(in.UserId))
	if err != nil {
		return nil, fmt.Errorf("用户冻结失败")
	}
	return &goodssrv.UserExitResponse{}, nil
}
